<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>编辑主要用药情况从表</title>
    <#include "/common/resource.ftl">
    <script type="text/javascript">
        $(function () {
            <#if (params.healthId)??>
            $.ajaxRequest({
                url: '${params.contextPatd}/web/elderPharmacy/query.json',
                data: {elderHealthId: "${params.healthId}"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var record = data.data;
                    console.log(record)
                    for (var i = 0; i < record.length; i++) {
                        var row = record[i];
                        $("input[name='medicinalName']:eq("+i+")").val(row.medicinalName);
                        $("input[name='medicinalUse']:eq("+i+")").val(row.medicinalUse);
                        $("input[name='medicinalNumber']:eq("+i+")").val(row.medicinalNumber);
                        $("input[name='medicinalTime']:eq("+i+")").val(row.medicinalTimeStr);
                        var medicinalCompliance = row.medicinalCompliance;
                        $("select[name='medicinalCompliance']:eq("+i+")").val(medicinalCompliance);
                        $("select[name='medicinalCompliance']:eq("+i+")>option:eq("+medicinalCompliance+")").attr("selected", true);
                    }
                    var  form = layui.form;
                    form.render();
                    // for (var key in record) {
                    //     $("[name='" + key + "']").val(record[key]);
                    // }
                }
            });
            </#if>
        });
    </script>
    <link rel="stylesheet" href="${params.contextPatd}/static/plug/layui/css/layui.css">
    <style>
        .layui-form select {display:none !important;}
    </style>
</head>
<body>
<div class="ui-form">
    <#if (params.healthId)??>
    <form class="layui-form ajax-form"
          action="${params.contextPatd}/web/elderPharmacy/<#if (params.id)??>modify<#else>save</#if>.json"
          metdod="post">
        <input type="hidden" name="elderHealthId" value="${params.healthId}"/>

        <table style="width: 100%; border: #DDDDDD; text-align: left;" border="1" cellpadding="20" cellspacing="0">
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalName" placeholder="请输入药物名称" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalUse" placeholder="请输入用法" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalNumber" placeholder="请输入用量" class="layui-input"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" name="medicinalTime" placeholder="请输入用药时间" class="layui-input ui-date {required:true}" readonly/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <select name="medicinalCompliance" class="layui-input">
                            <option value="">依从性</option>
                            <option value="规律">规律</option>
                            <option value="间断">间断</option>
                            <option value="不服药">不服药</option>
                        </select>
                    </div>
                </td>
            </tr>
        </table>
        <div class="layui-form-item" style="margin-top: 10%; margin-left: 40%;">
            <div class="layui-input-block">
                <input type="submit" value="保存" class="layui-btn"/>
            </div>
        </div>
    </form>
    <#else>
        请先保存老人健康基本信息!
    </#if>
</div>
</body>
<script src="${params.contextPatd}/static/plug/layui/layui.all.js"></script>
<script>
    $(function () {
        layui.use(['element', 'layer','form'], function () {
            var  form = layui.form;
            form.render();
        });
    });
</script>
</html>
